home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 028a / zip10ex.zip / DIR_OS2.H < prev    next >
C/C++ Source or Header  |  1991-10-03  |  2KB  |  70 lines

  1. /*
  2.  * @(#) dir.h 1.4 87/11/06   Public Domain.
  3.  *
  4.  *  A public domain implementation of BSD directory routines for
  5.  *  MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
  6.  *  August 1987
  7.  *
  8.  *  Enhanced and ported to OS/2 by Kai Uwe Rommel; added scandir() prototype
  9.  *  December 1989, February 1990
  10.  *  Change of MAXPATHLEN for HPFS, October 1990
  11.  */
  12.  
  13.  
  14. #define MAXNAMLEN  256
  15. #define MAXPATHLEN 256
  16.  
  17. #define A_RONLY    0x01
  18. #define A_HIDDEN   0x02
  19. #define A_SYSTEM   0x04
  20. #define A_LABEL    0x08
  21. #define A_DIR      0x10
  22. #define A_ARCHIVE  0x20
  23.  
  24.  
  25. struct direct
  26. {
  27.   ino_t    d_ino;                   /* a bit of a farce */
  28.   int      d_reclen;                /* more farce */
  29.   int      d_namlen;                /* length of d_name */
  30.   char     d_name[MAXNAMLEN + 1];   /* null terminated */
  31.   /* nonstandard fields */
  32.   long     d_size;                  /* size in bytes */
  33.   unsigned d_mode;                  /* DOS or OS/2 file attributes */
  34.   unsigned d_time;
  35.   unsigned d_date;
  36. };
  37.  
  38. /* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel).
  39.  * The find_first and find_next calls deliver this data without any extra cost.
  40.  * If this data is needed, these fields save a lot of extra calls to stat() 
  41.  * (each stat() again performs a find_first call !).
  42.  */
  43.  
  44. struct _dircontents
  45. {
  46.   char *_d_entry;
  47.   long _d_size;
  48.   unsigned _d_mode, _d_time, _d_date;
  49.   struct _dircontents *_d_next;
  50. };
  51.  
  52. typedef struct _dirdesc
  53. {
  54.   int  dd_id;                   /* uniquely identify each open directory */
  55.   long dd_loc;                  /* where we are in directory entry is this */
  56.   struct _dircontents *dd_contents;   /* pointer to contents of dir */
  57.   struct _dircontents *dd_cp;         /* pointer to current position */
  58. }
  59. DIR;
  60.  
  61.  
  62. extern int attributes;
  63.  
  64. extern DIR *opendir(char *);
  65. extern struct direct *readdir(DIR *);
  66. extern void seekdir(DIR *, long);
  67. extern long telldir(DIR *);
  68. extern void closedir(DIR *);
  69. #define rewinddir(dirp) seekdir(dirp, 0L)
  70.